package middleware

import (
	"github.com/gin-gonic/gin"
	"github.com/go-admin-team/go-admin-core/sdk/api"
	"github.com/go-admin-team/go-admin-core/sdk/pkg"
)

func InitMiddleware(r *gin.Engine) {

	// 添加 requestID
	r.Use(RequestId(pkg.TrafficKey))
	// 添加 go-admin-logger-request
	r.Use(api.SetRequestLogger)

	// 日志处理
	r.Use(LoggerToFile())

	// 数据库链接
	r.Use(WithContextDb)
	// 跨域处理
	r.Use(Options)
	// Secure is a middleware function that appends security
	r.Use(Secure)
}
